package com.edu.admin.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edu.admin.common.BaseService;
import com.edu.admin.entity.SysClassesTeacher;
import com.edu.admin.mapper.ClassesTeacherMapper;
import com.edu.admin.vo.ClassesTeacherVo;

/**
 * 班级学科教师服务
 *
 * @author Wangjiong
 *
 */
@Transactional
@Service
public class ClassesTeacherService extends BaseService<ClassesTeacherMapper, SysClassesTeacher> {
	
	
	/**
	 * 获取班级教师信息
	 * 
	 * @param teacherId
	 * 
	 * @return List<ClassesTeacherVo>
	 */
	public List<ClassesTeacherVo> getClassesTeacherByTeacherId(Long teacherId) {
		
		List<ClassesTeacherVo> classesTeacherList = this.mapper.getClassesTeacherByTeacherId(teacherId);
		
		return classesTeacherList;
	}
	
		
	/**
	 * 班级学科教师保存
	 * 
	 * @param classesId
	 * @param subjectId
	 * @param ids
	 *  
	 * @return
	 */
	public void saveClassesTeacher(Long classesId,Long subjectId,Long[] ids) {
        if(ids == null && classesId!=null && subjectId!=null){
        	this.mapper.deleteClassesTeacherByClassesIdAndTeacherId(classesId, subjectId);
            return;
        }
        
        this.mapper.deleteClassesTeacherByClassesIdAndTeacherId(classesId, subjectId);
        
        for (int i = 0;i < ids.length;i++){
        	SysClassesTeacher classesTeacher = new SysClassesTeacher();
        	classesTeacher.setClassesId(classesId);
        	classesTeacher.setSubjectId(subjectId);
        	classesTeacher.setTeacherId(ids[i]);
            insert(classesTeacher);
        }

    }


}
